const inquirer = require('inquirer')
const {templateAction} = require('./download')
var ncp = require('ncp').ncp;
var { promisify } = require('util')
var ncpPro = promisify(ncp)
const createAction = async (name,args)=>{
   
    const projectName = name
    const projectOption = args
    // const answer = await inquirer.prompt([
    //     /* Pass your questions in here */
    //     {
    //         type:'input',//这个问题的类型
    //         name: 'username',//用该变量接收input的内容
    //         message:'your name',
    //     },{
    //         type:'list',
    //         name:'hobby',
    //         message:'你的爱好',
    //         choices:['music','paint','movie']
    //     },{
    //         type:'confirm',
    //         name:'isOk',
    //         message:'是否正确',
    //     }
    // ])
    const p =[{
        type:'list',
        name:'framwork',
        message:'node框架',
        choices:['koa','express','egg']
    }]
    const answer = await inquirer.prompt(p)
    if(answer.framwork == 'koa'){
      let tempPath =  templateAction(answer.framwork)
      try {
        await ncpPro(tempPath,process.cwd().replace(/\\/g,'/') + projectName)
        
      } catch (error) {
        console.log(error)
      }
    }
    console.log(answer)
}
const configAction = (name,args)=>{
    console.log(name)
    console.log(args)
}

module.exports = {createAction,configAction}